package top.scsoul.pas.bean;

/**
 * 全局返回对象
 * - 错误码
 * - 数据
 * - 消息
 */
public class XhrResponse {
    private int code;
    private Object data;
    private String message;

    public static XhrResponse success() {
        return new XhrResponse(200, null, "操作成功");
    }

    public static XhrResponse success(Object data) {
        return new XhrResponse(200, data, "操作成功");
    }

    public static XhrResponse success(Object data, String message) {
        return new XhrResponse(200, data, message);
    }

    public static XhrResponse error(int code) {
        return new XhrResponse(code, null, "操作失败");
    }

    public static XhrResponse error(String message) {
        return new XhrResponse(0, null, message);
    }

    public static XhrResponse error(int code, String message) {
        return new XhrResponse(code, null, message);
    }

    public static XhrResponse error(int code, Object data, String message) {
        return new XhrResponse(code, data, message);
    }

    public XhrResponse(int code, Object data, String message) {
        this.code = code;
        this.data = data;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
